package common.interfaces;

import java.io.File;
import java.util.List;

import common.types.FictionalCharacter;
import common.types.Pair;

public interface ConfigurationsInterface {

	/**
	 * This method will get characters that have <code>name</code> as part of there name.</br>
	 * For example: for name "spider" will get characters having the name "The amazing
	 * spiderman", "spiderman" and so on...
	 * 
	 * @param name
	 * @param limit - Limit for the length of the results list.
	 * @return A pair holding a List of the found characters and the amount of results that were actually found.
	 * @throws Exception
	 */
	public Pair<List<FictionalCharacter>,Integer> getCharactersByName(String name, int limit) throws Exception;
	
	/**
	 * This method removes a character.
	 * 
	 * @param CID - The character key.
	 * @return True if success and False if character wasn't found.
	 * @throws Exception
	 */
	public boolean removeCharacter(FictionalCharacter character) throws Exception;
	
	/**
	 * This method updates the character information.
	 * 
	 * @param character - The update.
	 * @return True if success and False if character wasn't found.
	 * @throws Exception
	 */
	public boolean updateCharacter(FictionalCharacter character) throws Exception;
	
	/**
	 * This method creates a new character.
	 * 
	 * @param character - The new character.
	 * @return True if success and False if already exist.
	 * @throws Exception
	 */
	public boolean createCharacter(FictionalCharacter character) throws Exception;
	
	/**
	 * Imports the fictional universe datadump to the databse
	 * if onlineImport is true, freeBaseRoot will be ignored, otherwise, it will server as the root
	 * of the fictional universe datadump
	 * 
	 * @param guiSessionID the gui session id
	 * @param onlineImport if true, the latest datadump will be downloaded
	 * @param freeBaseRoot a reference to the fictional_universe archive or null if online import
	 * @return true on success, false otherwise
	 * @throws Exception
	 */
	public boolean importToDB(int guiSessionID, boolean onlineImport, File freeBaseArchive) throws Exception;
	
     /**
     * Releases all database resources
     */
    public void closeResources() throws Exception;
    
    /**
     * This method removes all user session if guiSession == -1, and all but the current guiSessionID otherwise
     * @throws Exception
     */
    void forceGuiSessionCleanup(int guiSessionID) throws Exception;

    /**
     * Removes given guiSession
     * @param guiSessionID
     * @throws Exception
     */
    public void cleanGUISession(int guiSessionID) throws Exception;
}
